package com.supermap.authentication.service.impl;

import com.supermap.authentication.common.ReadXML;
import com.supermap.authentication.service.IAuthenticationService;

import java.net.MalformedURLException;
import java.net.URL;

import org.codehaus.xfire.client.Client;
import org.springframework.stereotype.Service;

/**
 * Created by xiaolu on 2017/10/7.
 */
@Service
public class AuthenticationServiceImpl implements IAuthenticationService {
    @Override
    public String extractMethod(String methodName, Object[] param) {
        String result = null;
        String urlStr = ReadXML.getInstance().getList().get("web_service_url");
        Client c = null;
        try {
            URL url = new URL(urlStr);
            c = new Client(url);
            Object[] o = c.invoke(methodName, param);
            result = o[0].toString();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (c != null) {
                c.close();
            }
        }
        return result;
    }
}
